package com.example.demospringboot.netty.http.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author chenlei
 * @date 2020-01-07
**/
public class HttpServerInitializer extends ChannelInitializer<SocketChannel>{

	/* 
	 * @author chenlei
	 * @date 2020-01-07
	 * @description 
	 * @see io.netty.channel.ChannelInitializer#initChannel(io.netty.channel.Channel)
	 */
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		pipeline.addLast(new HttpServerCodec());
		pipeline.addLast("httpAggregator",new HttpObjectAggregator(512*1024));
		pipeline.addLast(new HttpRequestHandler());
	}

}
